package com.xxx.mall.api;

import com.xxx.mall.dto.RefreshTokenDTO;
import com.xxx.mall.manager.TokenStore;
import com.xxx.mall.response.R;
import com.xxx.mall.vo.TokenInfoVO;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * @author 邢晨旭
 * {@code @date} 2023/11/16
 */
@RestController
public class TokenApi {

    @Resource
    TokenStore tokenStore;

    @PostMapping("/ua/token/refresh")
    public R<TokenInfoVO> refresh(@RequestBody @Valid RefreshTokenDTO refreshTokenDTO) {
        return R.ok(tokenStore.refreshToken(refreshTokenDTO.getRefreshToken()));
    }

}
